package com.info.springmongo.common;

import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

@Getter
@Setter
@AllArgsConstructor
@NoArgsConstructor
public class ResultCode<T> {

    private int code = 0;

    private String msg;

    private T data;

    public ResultCode(T data) {
        this.data = data;
    }

    public ResultCode(int code, String msg) {
        this.code = code;
        this.msg = msg;
    }

    public static ResultCode success() {
        return new ResultCode();
    }

    public static <T> ResultCode<T> success(T data) {
        return new ResultCode(data);
    }


    public static  ResultCode fail(String msg) {
        return new ResultCode(500,msg);
    }

}
